home *** CD-ROM | disk | FTP | other *** search
- /*
- * The original copyright owners of the accompanying source code files have
- * agreed to place such code into the public domain. Accordingly, anyone
- * who receives or obtains a copy of such source code is freely entitled to
- * reproduce, use and otherwise exploit such code (including the right to
- * make derivative works), at his/her own risk and expense, without any
- * obligation or liability to the original copyright owners.
- *
- * We would appreciate (but do not require) that the following message be
- * included in any derivative works:
- *
- * "Portions of this program were developed by Peter Broadwell, Rob Myers
- * and Robin Schaufler while working in Silicon Valley."
- *
- * The accompanying source code files and related documentation materials
- * are distributed on an "AS IS" basis, without any warranties or
- * guarantees of any kind. All implied warranties, including the implied
- * warranties of merchantability and of fitness for any particular purpose,
- * are expressly disclaimed.
- */
- #include "gl.h"
- #include "math.h"
- #include "geom.h"
- #include "colors.h"
- #include "classIds.h"
- #include "objIds.h"
-
- /*
- * render floor for the master panel
- */
- buildFloor(r, id)
- register rectangle *r;
- Object id;
- {
- static inited = FALSE;
-
- if (inited) return;
- else inited = TRUE;
-
- makeobj(id);
- fishColor(PANEL_BLACK);
- rectfi(0,0, r->extent.x, r->extent.y);
- fishColor(PANEL_GRAY3);
- cmov2i(10,12);
- charstr("Camera Controls");
- closeobj();
- }
-
-
- point2d cam1shaftPoints[] = {
- { 0, 0, }, /* gratuitous 0th point */
- { 0, 0, },
- { 25, 2, },
- { 45, 4, },
- { 50, 5, },
- { 66, 10, },
- { 72, 15, },
- { 75, 20, },
- { 75,-10, },
- { 72,-15, },
- { 66,-20, },
- { 50,-25, },
- { 25,-28, },
- { 0,-30, },
- };
- /* null terminated polys, double null at end */
- long cam1shaftVertices[] = {
- 1,2,12,13,0,
- 2,3,4,11,12,0,
- 4,5,10,11,0,
- 5,6,9,10,0,
- 6,7,8,9,0,
- 0,
- };
-
- point2d cam1headPoints[] = {
- { 0, 0, }, /* gratuitous 0th point */
- { 45, 4, },
- { 35, 17, },
- { 55, 43, },
- { 55, 33, },
- { 66, 30, },
- { 72, 25, },
- { 75, 20, },
- { 72, 15, },
- { 66, 10, },
- { 50, 5, },
- };
- /* null terminated polys, double null at end */
- long cam1headVertices[] = {
- 1,2,3,4,0,
- 1,4,5,6,7,8,9,10,0,
- 0,
- };
-
-
- /*
- * render camera left-right valuator
- */
- buildCam1(r, id)
- register rectangle *r;
- Object id;
- {
- static inited = FALSE;
-
- if (inited) return;
- else inited = TRUE;
-
- makeobj(CAM1PART1);
- fishColor(PANEL_GRAY5);
- drawpolys(cam1shaftPoints, cam1shaftVertices);
- fishColor(PANEL_BLACK);
- drawpolys(cam1headPoints, cam1headVertices);
- closeobj();
-
- makeobj(id);
- pushmatrix();
- fishColor(PANEL_GRAY3);
- rectfi(0,0, r->extent.x,r->extent.y);
- fishColor(REAL_BLACK);
- recti(0,0, r->extent.x,r->extent.y);
-
- translate((float)(r->extent.x/2), (float)(r->extent.y/2), 0.0);
- scale(0.95, -0.95, 1.0);
- callobj(CAM1PART1);
- pushmatrix();
- scale(-1.0, 1.0, 1.0);
- callobj(CAM1PART1);
- popmatrix();
- pushmatrix();
- rotate(900, 'z');
- callobj(CAM1PART1);
- pushmatrix();
- scale(-1.0, 1.0, 1.0);
- callobj(CAM1PART1);
- popmatrix();
- popmatrix();
- popmatrix();
- closeobj();
- }
-
- point2d cam2Points[] = {
- { 0, 0, }, /* gratuitous 0th point */
- { 21, 10, },
- { 4, 20, },
- { 16, 20, },
- { 28, 20, },
- { 40, 20, },
- { 1,120, },
- { 16,120, },
- { 45,120, },
- { 60,120, },
- { 34,140, },
- };
- /* null terminated polys, double null at end */
- long cam2Vertices[] = {
- 1,2,3,4,5,0,
- 3,4,8,7,0,
- 6,7,8,9,10,0,
- 0,
- };
-
-
- /*
- * render camera zoom valuator
- */
- buildCam2(r, id)
- register rectangle *r;
- Object id;
- {
- static inited = FALSE;
-
- if (inited) return;
- else inited = TRUE;
-
- makeobj(CAM2PART1);
- drawpolys(cam2Points, cam2Vertices);
- closeobj();
-
- makeobj(id);
- pushmatrix();
- fishColor(PANEL_GRAY3);
- pmv2i(0,0); pdr2i(38,0);
- pdr2i(r->extent.x,r->extent.y); pdr2i(0,r->extent.y);
- pclos();
-
- pushmatrix();
- fishColor(PANEL_BLACK);
- translate(-2.0, 2.0, 0.0);
- scale(1.0, 1.05, 1.0);
- callobj(CAM2PART1);
- popmatrix();
- pushmatrix();
- fishColor(PANEL_GRAY5);
- translate(2.0, 0.0, 0.0);
- callobj(CAM2PART1);
- popmatrix();
-
- fishColor(REAL_BLACK);
- move2i(0,0); draw2i(38,0);
- draw2i(r->extent.x,r->extent.y); draw2i(0,r->extent.y);
- draw2i(0,0);
- popmatrix();
- closeobj();
- }
-
-
- /*
- * render camera "HOME" button
- */
- buildCam3(r, id, hid)
- register rectangle *r;
- Object id, hid;
- {
- static inited = FALSE;
-
- if (inited) return;
- else inited = TRUE;
-
- makeobj(id);
- fishColor(PANEL_BLACK);
- rectfi(0,0, r->extent.x, r->extent.y);
- fishColor(PANEL_GRAY5);
- cmov2i(2,10);
- charstr("HOME");
- closeobj();
- makeobj(hid);
- fishColor(PANEL_GRAY5);
- recti(0,0, r->extent.x, r->extent.y);
- cmov2i(2,10);
- charstr("HOME");
- closeobj();
- }
-
- /*
- * render sophistication valuator
- */
- buildSoph(r, id, hid)
- register rectangle *r;
- Object id, hid;
- {
- char *str;
- static inited = FALSE;
-
- if (inited) return;
- else inited = TRUE;
-
- makeobj(id);
- fishColor(PANEL_GRAY3);
- rectfi(0,0, r->extent.x, r->extent.y);
- fishColor(REAL_BLACK);
- recti(0,0, r->extent.x, r->extent.y);
- fishColor(PANEL_GRAY5);
- cmov2i(4,12);
- charstr("Sophisticated");
- str = "Popular";
- cmov2i(r->extent.x - 4 - strwidth(str),12);
- charstr(str);
- closeobj();
- makeobj(hid);
- fishColor(PANEL_WHITE);
- pmv2i(0,0);
- pdr2i(4, 10);
- pdr2i(-4,10);
- pclos();
- closeobj();
- }
-
- /*
- * build a plain vanilla absolute valuator consisting of a box
- * containing a sliding bar, and a label below it.
- */
- bldVanillaVal(r, id, tid, str)
- register rectangle *r;
- Object id, /* id of compiled object for painter */
- tid; /* id of compiled object for tracker */
- char *str; /* label below valuator */
- {
- point2d extent;
-
- makeobj(id);
- extent.x = max(r->extent.x, strwidth(str));
- extent.y = max(6, r->extent.y - getheight());
- fishColor(PANEL_GRAY3);
- rectfi(0,0, extent.x, extent.y);
- fishColor(REAL_BLACK);
- recti(0,0, extent.x, extent.y);
- fishColor(PANEL_GRAY5);
- cmov2i(0, r->extent.y);
- charstr(str);
- closeobj();
-
- r->extent = extent;
- makeobj(tid);
- fishColor(PANEL_WHITE);
- rectfi(-(extent.x>>1)+2,-1, (extent.x>>1)-2, 1);
- closeobj();
- }
-
- /*
- * render individual's control panel floor
- */
- buildIndFloor(r, id)
- register rectangle *r;
- Object id;
- {
- static inited = FALSE;
-
- if (inited) return;
- else inited = TRUE;
-
- makeobj(id);
- fishColor(PANEL_BLACK);
- rectfi(0,0, r->extent.x, r->extent.y);
- closeobj();
- }
-
- /*
- * render individual's scaling valuator
- */
- buildIndSize(r, clientClass, id, tid)
- register rectangle *r;
- int clientClass;
- Object id, tid;
- {
- static inited = FALSE;
-
- makeobj(id);
- fishColor(PANEL_GRAY3);
- rectfi(0,0, r->extent.x, r->extent.y);
- fishColor(PANEL_BLACK);
- move2i(0,0);
- draw2i(r->extent.x-12, r->extent.y);
- draw2i(r->extent.x-12, 0);
- fishColor(REAL_BLACK);
- recti(0,0, r->extent.x, r->extent.y);
- fishColor(PANEL_GRAY5);
- drawfish(clientClass, 0.045, r->extent.x -18, 20);
- drawfish(clientClass, 0.015, r->extent.x -12, r->extent.y-16);
-
- /*
- fishColor(PANEL_GRAY5);
- cmov2i(12,18);
- charstr("Size");
- */
- closeobj();
-
- if (!inited) {
- inited = TRUE;
-
- makeobj(tid);
- fishColor(PANEL_WHITE);
- pmv2i(15,0);
- pdr2i(24, 5);
- pdr2i(24, -5);
- pclos();
- closeobj();
- }
- }
-
- /*
- * render individual's heading controls
- */
- /* ARGSUSED */
- buildIndHeading(r, clientClass, id, tid)
- register rectangle *r;
- int clientClass;
- Object id, tid;
- {
- char *str;
- static inited = FALSE;
-
- if (!inited) {
- inited = TRUE;
-
- makeobj(INDSUBHEAD);
- fishColor(PANEL_GRAY3);
- arcfi(60, 130, 130, -1200, -600);
- fishColor(PANEL_BLACK);
- arcfi(60, 130, 65, -1210, -590);
- fishColor(REAL_BLACK);
- arci(60, 130, 130, -1200, -600);
- arci(60, 130, 65, -1210, -590);
- move2i(93, 74); draw2i(125, 18);
- move2i(27, 74); draw2i( -5, 18);
-
- fishColor(PANEL_GRAY5);
- str = "Direction";
- cmov2i(60-(strwidth(str)/2), 18);
- charstr(str);
- closeobj();
- }
-
- makeobj(id);
- callobj(INDSUBHEAD);
- /****
- fishColor(PANEL_GRAY3);
- if (clientClass == GUPPY) {
- str = "Guppy Controls";
- }
- else if (clientClass == MINNOW) {
- str = "Minnow Controls";
- }
- else str = "Fish Controls";
- cmov2i(60-(strwidth(str)/2), 90);
- charstr(str);
- *****/
- closeobj();
-
- makeobj(tid);
- fishColor(PANEL_WHITE);
- circfi(0,0,5);
- closeobj();
- }
-
- point2d guppySidePoints[] = {
- { 0, 0, }, /* gratuitous 0th point */
- { 600, 000, },
- { 000, 000, },
- { 150, -320, },
- { 300, -320, },
- { 510, -250, },
- { 590, -150, },
- /* tail */
- { 100, -200, },
- { -200, 400, },
- { -200, -500, },
- };
- /* null terminated polys, double null at end */
- long guppySideVertices[] = {
- 1,2,3,4,5,6,0,
- 7,8,9,0,
- 0,
- };
-
- point2d minnowSidePoints[] = {
- { 0, 0, }, /* gratuitous 0th point */
- { 000, 000, },
- { 200, -300, },
- { 730, -130, },
- { 710, -100, },
- { 750, -030, },
- { 300, 300, },
- /* tail */
- { 000, 000, },
- { -300, 400, },
- { -300, -550, },
- };
- /* null terminated polys, double null at end */
- long minnowSideVertices[] = {
- 1,2,3,4,5,6,0,
- 7,8,9,0,
- 0,
- };
-
-
- /*
- * render individual's azimuth valuator
- */
- buildIndAzimuth(r, clientClass, id, tid)
- register rectangle *r;
- int clientClass;
- Object id, tid;
- {
- int i, rad;
- static inited = FALSE;
-
- if (!inited) {
- inited = TRUE;
-
- makeobj(id);
- fishColor(PANEL_GRAY3);
- rectfi(0,0, r->extent.x, r->extent.y);
- fishColor(REAL_BLACK);
- recti(0,0, r->extent.x, r->extent.y);
- /* top edge (waves) */
- rad = r->extent.x/6 + 1;
- for (i=rad-1; i<= r->extent.x - rad+6; i += 2*(rad-1)) {
- fishColor(PANEL_BLACK);
- arcfi(i, -4, rad, 0, 1800);
- }
- /* bottom edge (pebbles) */
- rad = r->extent.x/12;
- for (i=rad+1; i<= r->extent.x - 3; i += 2*rad) {
- fishColor(PANEL_BLACK);
- arcfi(i, r->extent.y + (i % 3) + 2, rad + (i % 2), 1800, 3600);
- }
- /*
- fishColor(PANEL_GRAY5);
- cmov2i(12,18);
- charstr("Rise");
- */
- closeobj();
- }
-
- makeobj(tid);
- fishColor(PANEL_WHITE);
- drawfish(clientClass, 0.03, 6,0);
- closeobj();
- }
-
-
- /*
- * render individual's speed valuator
- */
- buildIndSpeed(r, clientClass, id, tid)
- register rectangle *r;
- int clientClass;
- Object id, tid;
- {
- int i;
- static inited = FALSE;
-
- if (!inited) {
- inited = TRUE;
-
- makeobj(id);
- fishColor(PANEL_GRAY3);
- rectfi(0,0, r->extent.x, r->extent.y);
- fishColor(REAL_BLACK);
- recti(0,0, r->extent.x, r->extent.y);
- closeobj();
- }
- makeobj(tid);
- fishColor(PANEL_WHITE);
- drawfish(clientClass, 0.02, 0,0);
-
- fishColor(PANEL_GRAY5);
- move2i(10, 0);
- for (i=0; i<r->extent.x - 10; i+=3) {
- draw2i(i+10, (int)(3.0 * sin((float)(i)*0.3)));
- }
- closeobj();
- }
-
- /*
- * render individual's snuff button
- */
- buildIndSnuff(r, clientClass, id, tid)
- register rectangle *r;
- int clientClass;
- Object id, tid;
- {
- char *str;
-
- makeobj(id);
- pushmatrix();
- fishColor(PANEL_GRAY3);
- rectfi(0,0, r->extent.x, r->extent.y);
- fishColor(REAL_BLACK);
- recti(0,0, r->extent.x, r->extent.y);
- fishColor(PANEL_GRAY5);
- /* drawfish(clientClass, -0.04, r->extent.x/2-5, r->extent.y/2);/**/
- drawfish(clientClass, -0.025, r->extent.x/2-5, r->extent.y/2);
- fishColor(PANEL_BLACK);
- linewidth(2);
- /***
- move2i(r->extent.x/2-15, r->extent.y/2-15);
- draw2i(r->extent.x/2+15, r->extent.y/2+15);
- move2i(r->extent.x/2+15, r->extent.y/2-15);
- draw2i(r->extent.x/2-15, r->extent.y/2+15);
- ****/
- move2i(r->extent.x/2-10, r->extent.y/2-10);
- draw2i(r->extent.x/2+10, r->extent.y/2+10);
- move2i(r->extent.x/2+10, r->extent.y/2-10);
- draw2i(r->extent.x/2-10, r->extent.y/2+10);
- linewidth(1);
- popmatrix();
- /**************
- str = "Expire";
- cmov2i(r->extent.x/2 - strwidth(str)/2, r->extent.y-10);
- charstr(str);
- /**************/
- closeobj();
-
- makeobj(tid);
- fishColor(PANEL_GRAY5);
- str = "Expire";
- cmov2i(r->extent.x/2 - strwidth(str), r->extent.y-5);
- charstr(str);
- closeobj();
- }
-
-
- /*
- * render test menu
- */
- buildMenu1(r, nbuttons, id, tid)
- register rectangle *r;
- point2d *nbuttons;
- Object id, tid;
- {
- makeobj(id);
- fishColor(PANEL_GRAY3);
- rectfi(0,0, r->extent.x, r->extent.y);
- fishColor(REAL_BLACK);
- recti(0,0, r->extent.x, r->extent.y);
- closeobj();
- makeobj(tid);
- fishColor(PANEL_GRAY5);
- recti(0,0, r->extent.x/nbuttons->x, r->extent.y/nbuttons->y);
- popmatrix();
- closeobj();
- }
-
-
- /*
- * render individual's color valuator set
- */
- /* ARGSUSED */
- buildCol(r, clientColor, id1, id2, tid)
- register rectangle *r;
- int clientColor;
- Object id1, id2, tid;
- {
- static point2d box1, box2;
- static inited = FALSE;
-
- if (!inited) {
- inited = TRUE;
-
- setpt2d(&box2, (r->extent.x-10)/4, r->extent.y);
- setpt2d(&box1, 3*box2.x, r->extent.y);
-
- makeobj(id1);
- fishColor(RED);
- rectfi(0, 0, box1.x/3, 10);
- rectfi(0,box1.y - 10, box1.x/3, box1.y);
- fishColor(GREEN);
- rectfi(box1.x/3, 0, (2*box1.x)/3, 10);
- rectfi(box1.x/3, box1.y-10, (2*box1.x)/3, box1.y);
- fishColor(BLUE);
- rectfi((2*box1.x)/3, 0, box1.x, 10);
- rectfi((2*box1.x)/3, box1.y-10, box1.x, box1.y);
- closeobj();
- makeobj(id1);
- fishColor(BLACK);
- /* rectfi(box1.x+10, 0, box2.x, 10); /* */
- rectfi(0, 0, box2.x, 10);
- fishColor(WHITE);
- /* rectfi(box1.x+10, 10, box2.x, box2.y); /* */
- rectfi(0, 10, box2.x, box2.y);
- closeobj();
- }
- makeobj(tid);
- fishColor(clientColor);
- rectfi(0,10, box1.x, box1.y-20);
- rectfi(box1.x+10, 10, box2.x, box2.y-20);
- /* rectfi(box1.x+10, 10, box2.x, box2.y); /* */
- closeobj();
- }
-
-
-
- drawfish(clientClass, size, x,y)
- int clientClass;
- float size;
- int x,y;
- {
- pushmatrix();
- translate((float)x, (float)y, 0.0);
- if (clientClass == GUPPY) {
- scale(-(size*1.1), -(size*1.1), size);
- drawpolys(guppySidePoints, guppySideVertices);
- }
- else if (clientClass == MINNOW) {
- scale(-(size*0.9), -size, size);
- drawpolys(minnowSidePoints, minnowSideVertices);
- }
- else {
- circfi(0, 0, 6);
- }
- popmatrix();
- }
-
- /*
- * draw 2d polygon from a point dictionary and vertex list
- */
- drawpolys(pnts, verts)
- register point2d *pnts;
- register long *verts;
- {
- register point2d *p;
-
- while(*verts) {
- p = &pnts[*(verts++)];
- pmv2i(p->x, p->y);
- while(*verts) {
- p = &pnts[*(verts++)];
- pdr2i(p->x, p->y);
- }
- pclos();
- verts++;
- }
- }
-